/*
 * @Author: JiraiyaChen 979526234@qq.com
 * @Date: 2025-02-12 13:50:21
 * @LastEditors: JiraiyaChen 979526234@qq.com
 * @LastEditTime: 2025-03-11 15:23:39
 * @Description: 弹框通用hook
 */

import { ref } from 'vue'
export const useDialog = (tableRef) => {
  const type = ref<string>('')
  // 新增/编辑 弹框
  const hookVisible = ref<boolean>(false)
  const onCloseDialog = (str) => {
    hookVisible.value = false
    if (str == 'refresh-table') tableRef?.value?.initTable()
    if (str == 'refresh-tree') tableRef?.value?.initTree()
  }
  // 编辑
  const dialogInfo = ref<any>({})
  const onOpenDialog = (row) => {
    dialogInfo.value = row
    hookVisible.value = true
  }
  return {
    type,
    hookVisible,
    dialogInfo,
    onOpenDialog,
    onCloseDialog
  }
}
